﻿using System.Net.Http.Headers;
using System.Reflection.Metadata.Ecma335;

namespace CodingExercises._1_25;

public class GetQualifiedPlayers
{
    // 从游戏排行榜中筛选符合条件的玩家
    public static List<string> Method1(Dictionary<string, int> playerScores)
    {
        const int MinimumScore = 50;
        const int CheatingScore = 100;
        var result = new List<string>();
        foreach (var item in playerScores)
        {
            if (item.Value < MinimumScore)
            {
                continue;
            }

            if (item.Value >= CheatingScore)
            {
                break;
            }

            result.Add(item.Key);
        }

        return result;
    }

    public static List<string> Method2(Dictionary<string, int> playerScores)
    {
        const int MinimumScore = 50;
        const int CheatingScore = 100;

        return playerScores
            .TakeWhile(item => item.Value < CheatingScore)
            .Where(item => item.Value >= MinimumScore)
            .Select(item => item.Key)
            .ToList();
    }
}